1 00:00:00,450 --> 00:00:05,970 Okay, so the next section in our game I think we can script is the module script that will be responsible 2 00:00:05,970 --> 00:00:08,370 for controlling the client's main guy. 3 00:00:08,400 --> 00:00:12,210 This guy is going to display the objectives players need to complete. 4 00:00:12,210 --> 00:00:14,910 It will display the intro message when we start the game. 5 00:00:14,910 --> 00:00:20,430 The outro message when a player escapes or fails to escape, it will control the spectating system and 6 00:00:20,430 --> 00:00:21,090 much more. 7 00:00:21,090 --> 00:00:28,110 So to get started, let's go ahead and open up our main UI handler and start our player scripts inside 8 00:00:28,110 --> 00:00:28,590 of here. 9 00:00:28,590 --> 00:00:33,120 For now, we're only going to need four services, but that might change in the future as we continue 10 00:00:33,120 --> 00:00:35,730 to add on more functionality to our main guy. 11 00:00:35,730 --> 00:00:38,100 But first we need replicated storage. 12 00:00:39,680 --> 00:00:42,500 The next service we'll need is the Tween Service. 13 00:00:44,150 --> 00:00:46,730 We're going to need the player service. 14 00:00:48,080 --> 00:00:51,110 And then we're going to need the sound service. 15 00:00:53,300 --> 00:00:57,890 Now, from this point, we can go ahead and make the table that will represent this module script. 16 00:00:57,890 --> 00:01:02,480 So we'll call it GUI handler and we'll make sure to return it at the end here. 17 00:01:02,990 --> 00:01:09,950 And then some other variables we'll need for now is we first want to refer to our GUI actions enum. 18 00:01:09,950 --> 00:01:15,980 So we'll require that for replicated storage and modules dot enums dot gui actions enum. 19 00:01:16,340 --> 00:01:24,530 And they're also going to want to get our game comms event which is also in replicated storage dot events, 20 00:01:24,530 --> 00:01:26,750 dot remotes, dot game communication. 21 00:01:26,750 --> 00:01:31,340 And then we're also going to want to get the game comms enum for this particular event. 22 00:01:31,520 --> 00:01:38,600 So we'll require remote storage, dot modules, dot enums, dot game communication enum. 23 00:01:38,690 --> 00:01:43,430 And then the other event we're going to need is the update GUI event. 24 00:01:44,670 --> 00:01:47,730 And that's in events dot remotes dot update guy. 25 00:01:47,970 --> 00:01:50,970 Now we're also going to make a reference to the local player. 26 00:01:53,720 --> 00:01:58,580 Because once we've gotten the local player, then we need to get our main guy. 27 00:01:58,580 --> 00:02:04,790 Since this module script is not going to be a child of our main guy, or basically it is not a local 28 00:02:04,790 --> 00:02:06,680 script, that's a child of the main guy. 29 00:02:06,680 --> 00:02:14,180 We need to refer to this guy by accessing the local players dot player guy folder, and we need to wait 30 00:02:14,180 --> 00:02:17,480 for this main guy to be replicated into this folder. 31 00:02:17,480 --> 00:02:22,160 And then once we finally get the guy, then we can go ahead and reference all of the different frames 32 00:02:22,160 --> 00:02:26,240 inside of it so we can make a variable for the death frame, for example. 33 00:02:26,240 --> 00:02:33,410 So guy dot death frame we can make a reference to the message frame guy dot message frame. 34 00:02:33,410 --> 00:02:36,800 And this is for the introduction message. 35 00:02:36,800 --> 00:02:40,670 We're going to make a reference to the objective frame. 36 00:02:40,670 --> 00:02:42,530 We'll just call it obj frame. 37 00:02:42,650 --> 00:02:44,960 So guy dot objective frame. 38 00:02:45,230 --> 00:02:52,130 And we'll want to make a reference to one of the example objectives that will appear in our objective 39 00:02:52,130 --> 00:02:52,430 frame. 40 00:02:52,430 --> 00:02:54,740 So we'll call it objective label. 41 00:02:54,860 --> 00:03:00,260 And that's object frame dot objective label example. 42 00:03:00,680 --> 00:03:03,410 We can also make a reference to our task frame. 43 00:03:03,410 --> 00:03:09,470 So guy dot task frame we can make a reference to our outro frame. 44 00:03:10,490 --> 00:03:15,410 Guitar outro frame, we can make a reference to the spectating frame guy. 45 00:03:15,740 --> 00:03:17,090 Spectate frame. 46 00:03:17,090 --> 00:03:24,140 We'll have a reference to a task label for our task frame as well, so we'll make it up here. 47 00:03:24,140 --> 00:03:30,440 Task labels equal to task frame dot uh task label example. 48 00:03:30,830 --> 00:03:35,840 We'll make a reference to the small little text label that will appear at the bottom of our screen. 49 00:03:35,840 --> 00:03:38,600 So we'll call it small message label. 50 00:03:39,390 --> 00:03:41,850 That's equal to give a small message label. 51 00:03:41,850 --> 00:03:45,270 And then we'll make a reference to our countdown label. 52 00:03:46,390 --> 00:03:51,190 Juiiet countdown label, and then we'll make a reference to that money frame. 53 00:03:51,990 --> 00:03:54,330 Jewish money collection frame. 54 00:03:54,870 --> 00:03:56,700 Now I'm going to create a table. 55 00:03:56,700 --> 00:03:58,050 I'm going to call it messages. 56 00:03:58,050 --> 00:04:03,240 And this table is going to store the messages we want to display onto the screen at the beginning of 57 00:04:03,240 --> 00:04:03,900 the game. 58 00:04:03,900 --> 00:04:05,640 That will fill up our message frame. 59 00:04:05,640 --> 00:04:09,750 So that will be passed when we get the GUI action. 60 00:04:09,750 --> 00:04:17,430 So let me pass in GUI actions enum and the action we want to do is the intro message. 61 00:04:17,430 --> 00:04:20,460 So what are the messages going to be for the intro message? 62 00:04:20,460 --> 00:04:27,330 Well, the first text in there is going to be the time which will be we'll do 11 p.m. the next message 63 00:04:27,330 --> 00:04:34,470 will be something like on a bus to the Krusty Krab for your first shift. 64 00:04:34,470 --> 00:04:37,620 This is to give some context to the players about what the game is about. 65 00:04:38,110 --> 00:04:45,010 And then we can tell them their most important objective, which is get enough money to pay for rent. 66 00:04:45,280 --> 00:04:46,180 And there we go. 67 00:04:46,210 --> 00:04:50,260 Now I'm also going to create a new RNG data type. 68 00:04:50,810 --> 00:04:53,810 And then I'm going to define two constants down here. 69 00:04:53,810 --> 00:04:55,580 And these are going to be two colors. 70 00:04:55,580 --> 00:04:57,740 So we're going to have a green color. 71 00:04:57,950 --> 00:05:00,200 And we're also going to have a red color. 72 00:05:00,290 --> 00:05:05,540 And these are the going to be the colors we're going to set for tasks and objective. 73 00:05:05,540 --> 00:05:10,130 So when we fulfill a task we'll set the task color to green and then fade it out. 74 00:05:10,130 --> 00:05:13,550 Or if we fail a task, we'll set it to red and then fade it out. 75 00:05:13,550 --> 00:05:16,910 So for our green color we could do color three dot from RGB. 76 00:05:17,060 --> 00:05:21,290 And then we could go in here and pick a nice green color, something like that. 77 00:05:21,290 --> 00:05:25,520 And then we can do the same thing for the red color color three dot from RGB. 78 00:05:25,520 --> 00:05:29,210 Open up our color wheel and pick some kind of red color like that. 79 00:05:29,570 --> 00:05:29,990 All right. 80 00:05:30,020 --> 00:05:32,000 Now some private functions we're going to need in here. 81 00:05:32,000 --> 00:05:35,630 The first private function we'll need is for fading UI elements. 82 00:05:35,630 --> 00:05:40,910 So instead of having to keep constantly using the tween service in our script multiple times to fade 83 00:05:40,910 --> 00:05:45,530 in or fade out UI elements, we should just create one function that can do all of it for us. 84 00:05:45,530 --> 00:05:47,960 So we're going to call this function fade element. 85 00:05:48,050 --> 00:05:51,320 We'll get past a UI element to this function. 86 00:05:51,320 --> 00:05:54,110 We'll get past the duration for the tween. 87 00:05:54,110 --> 00:05:58,220 And then what transparency we want to set for this particular UI element. 88 00:05:58,550 --> 00:06:02,120 And then inside of here what we're going to do is we're going to create a variable I'm going to call 89 00:06:02,120 --> 00:06:02,990 it tween. 90 00:06:03,320 --> 00:06:08,750 And what we're going to do is we're going to check what uh, class this UI element belongs to. 91 00:06:08,750 --> 00:06:16,070 So if this UI element is of the class for example frame, then that means we need to change the background 92 00:06:16,070 --> 00:06:17,900 transparency for this UI element. 93 00:06:17,900 --> 00:06:21,410 So we'll create a new tween on this UI element. 94 00:06:21,410 --> 00:06:25,550 We'll create a new tween info and pass the duration. 95 00:06:26,510 --> 00:06:33,050 And then we're going to set the background transparency equal to the transparency pass to the function. 96 00:06:33,050 --> 00:06:36,020 And then we can store this in our tween variable. 97 00:06:36,890 --> 00:06:42,020 Another thing we can check is if this UI element is, for example, a text label. 98 00:06:42,020 --> 00:06:49,160 So if it's a text label, then instead we need to fade out or fade in the text transparency instead. 99 00:06:49,160 --> 00:06:52,340 So we can replace this with text transparency. 100 00:06:53,620 --> 00:06:58,570 Let's say the UI element is a image label, right? 101 00:06:58,570 --> 00:07:00,430 Maybe we need to fade out one of those. 102 00:07:00,550 --> 00:07:02,770 Then we can do the exact same thing here. 103 00:07:02,770 --> 00:07:07,750 But instead we need to fade out the image transparency. 104 00:07:09,780 --> 00:07:19,860 Now, let's say the UI element is a UI stroke or basically the the outline that goes around specific 105 00:07:19,890 --> 00:07:20,670 UI elements. 106 00:07:20,670 --> 00:07:24,360 If it's UI stroke, then we need to create a new tween. 107 00:07:24,360 --> 00:07:28,740 And instead on this stroke we just need to change its transparency property. 108 00:07:29,270 --> 00:07:34,790 And then once we do that, we can check if tween is not nil, and if it isn't, then we can play our 109 00:07:34,790 --> 00:07:35,450 tween. 110 00:07:36,250 --> 00:07:39,670 And then we're going to have this, uh, function yield as well. 111 00:07:39,670 --> 00:07:43,000 So we're going to do dot completed and we're going to wait for it to complete. 112 00:07:43,000 --> 00:07:47,230 So just in case we need any functionality to wait for this tween to complete, we're going to do it 113 00:07:47,230 --> 00:07:47,830 here. 114 00:07:47,830 --> 00:07:52,810 But if we do not need to wait for this tween to complete, then we can simply just spawn this function 115 00:07:52,810 --> 00:07:57,490 in a new thread and we can go ahead and ignore this, uh, yield statement right here. 116 00:07:57,760 --> 00:08:03,700 Now, another private function we're going to need is for displaying the intro message so we can call 117 00:08:03,700 --> 00:08:07,060 it display intro message. 118 00:08:07,910 --> 00:08:10,880 Um, yeah, we'll just call it that display intro message. 119 00:08:11,180 --> 00:08:15,770 And what will happen is we'll get past this table here containing all the messages, so we can call 120 00:08:15,770 --> 00:08:17,240 it message table. 121 00:08:17,600 --> 00:08:20,450 And then we'll also have a duration between the different messages. 122 00:08:20,450 --> 00:08:23,450 So how long do we want to wait before we switch to the next message. 123 00:08:23,450 --> 00:08:24,740 And then to the next message. 124 00:08:24,740 --> 00:08:29,870 So we can call it delay between messages. 125 00:08:30,080 --> 00:08:35,180 Another function we're going to need is for updating, uh, our tasks. 126 00:08:35,180 --> 00:08:37,010 So we'll call it update task. 127 00:08:37,010 --> 00:08:40,040 And we'll get passed some arguments to this function. 128 00:08:40,040 --> 00:08:45,800 We may need a function to update all of our tasks instead of a specific task. 129 00:08:45,800 --> 00:08:47,720 So we can call update all tasks. 130 00:08:47,720 --> 00:08:53,870 And we'll get passed a task list or a list containing all of the tasks we need to update and put into 131 00:08:53,870 --> 00:08:55,550 our task frame. 132 00:08:56,170 --> 00:09:00,640 We'll have a function to fulfill a task, so we'll call it fulfill task. 133 00:09:00,700 --> 00:09:03,730 We'll get passed arguments to this function as well from the server. 134 00:09:03,730 --> 00:09:09,730 And then we'll want to have a function for updating all of the objectives. 135 00:09:09,730 --> 00:09:13,180 So if we need to create new objectives then we'll do that. 136 00:09:13,180 --> 00:09:17,980 So here uh we'll have a function for adding a new objective. 137 00:09:18,570 --> 00:09:22,950 Will also get past, uh, the objective itself to this function. 138 00:09:23,570 --> 00:09:27,290 We'll have a function to fulfill an objective. 139 00:09:28,250 --> 00:09:30,380 We'll get past arguments to this as well. 140 00:09:31,010 --> 00:09:35,540 And then we're also going to have the ability to fail an objective. 141 00:09:37,520 --> 00:09:39,080 It passed arguments to this. 142 00:09:39,590 --> 00:09:43,730 Another function we're going to need is for our small message label. 143 00:09:43,730 --> 00:09:47,510 So we can call this function display small message. 144 00:09:47,510 --> 00:09:51,440 And we would get past uh more arguments to this function as well. 145 00:09:51,740 --> 00:09:55,190 Another function we're going to need is to display when we collect money. 146 00:09:55,190 --> 00:09:58,220 So we can call this function display money frame. 147 00:09:58,370 --> 00:10:00,500 We'll get passed arguments to this one. 148 00:10:01,370 --> 00:10:05,600 We're also going to need a function for displaying our outro frame. 149 00:10:06,110 --> 00:10:08,960 We'll also get passed arguments to this one from the server. 150 00:10:08,990 --> 00:10:13,400 We're going to need a function for updating the countdown on our screen. 151 00:10:13,700 --> 00:10:15,500 Also need args for this one. 152 00:10:15,500 --> 00:10:18,560 And then we're also going to need a function for our spectating system. 153 00:10:18,560 --> 00:10:21,080 So we'll call it start spectating. 154 00:10:21,080 --> 00:10:23,690 And that will handle all of that kind of good stuff. 155 00:10:23,690 --> 00:10:30,440 And lastly we'll need a private function for displaying when we have died so we can call it display 156 00:10:30,440 --> 00:10:31,400 died frame. 157 00:10:32,470 --> 00:10:32,950 All right. 158 00:10:32,950 --> 00:10:39,190 So inside of the public function section we're going to create an initialize function for this. 159 00:10:40,380 --> 00:10:44,610 And then we're also going to create a start function for this. 160 00:10:44,610 --> 00:10:46,650 And this one's going to actually be very easy. 161 00:10:46,650 --> 00:10:51,060 All we're going to do here in the start function is that we're going to get our objective frame, and 162 00:10:51,060 --> 00:10:52,920 we're going to set the visibility equal to true. 163 00:10:52,920 --> 00:10:58,920 So when the game starts we're automatically going to have the objectives displayed on top of our screen. 164 00:10:59,370 --> 00:11:05,850 Now inside of the initialize section we're going to have to listen to our update guy event and get the 165 00:11:05,850 --> 00:11:08,820 on client event and connect a Lambda function to this. 166 00:11:08,820 --> 00:11:12,480 And we're going to get an action and argument supplied to that action from the server. 167 00:11:12,480 --> 00:11:17,310 So that means we're going to have to listen to all of those different actions within our GUI actions 168 00:11:17,310 --> 00:11:17,970 enum. 169 00:11:17,970 --> 00:11:24,240 Now there's another neat way that we could do this by instead of having a bunch of if else if else if 170 00:11:24,240 --> 00:11:28,680 statements for each of the different actions, we could actually create a table. 171 00:11:28,680 --> 00:11:30,780 And I'm going to call this table case. 172 00:11:31,230 --> 00:11:35,550 And this table is going to imitate something called a switch statement. 173 00:11:35,550 --> 00:11:41,430 Now a switch statement is a very useful statement where it gets passed a condition and it only executes 174 00:11:41,430 --> 00:11:47,280 a certain block of code based on whether or not that condition matches, you know, a particular section. 175 00:11:47,280 --> 00:11:52,290 Now, unfortunately, Lua doesn't have a switch statement, and switch statements can be a lot more 176 00:11:52,290 --> 00:11:54,990 performant than if else if else if statements. 177 00:11:54,990 --> 00:11:58,830 But we can imitate a switch statement by using a dictionary. 178 00:11:58,830 --> 00:12:01,560 So this dictionary can have a bunch of keys. 179 00:12:01,560 --> 00:12:03,990 And we pass a key to the dictionary. 180 00:12:03,990 --> 00:12:07,560 And then we execute a function that is connected to that key. 181 00:12:07,560 --> 00:12:14,850 So for example let's say for the GUI actions enum of update objectives, we can have it reference our 182 00:12:14,850 --> 00:12:16,710 update objectives function. 183 00:12:17,130 --> 00:12:22,260 We could also do this for our GUI actions enum dot objective fulfilled. 184 00:12:22,260 --> 00:12:28,170 We can have this reference are fulfilled uh fulfill objective function. 185 00:12:28,170 --> 00:12:29,880 Oops, it looks like I named that wrongly. 186 00:12:29,880 --> 00:12:31,110 Actually fixed that. 187 00:12:31,110 --> 00:12:32,400 Fulfill objective. 188 00:12:32,910 --> 00:12:41,130 We can do it for like guy actions enum dot objective failed and have that reference our failed objective 189 00:12:41,130 --> 00:12:41,910 function. 190 00:12:43,240 --> 00:12:44,560 Failed objective. 191 00:12:45,290 --> 00:12:49,040 We can do this for, um, updating tasks. 192 00:12:49,040 --> 00:12:56,450 So update tasks and we'll have this reference our update all task function. 193 00:12:56,450 --> 00:13:03,410 We'll do the same thing for GUI actions enum dot update task and have that reference our update task 194 00:13:03,410 --> 00:13:04,310 function. 195 00:13:04,670 --> 00:13:09,980 We can do this for the GUI actions enum for let's say adding an objective. 196 00:13:09,980 --> 00:13:12,740 So we'll reference the add objective function. 197 00:13:12,740 --> 00:13:14,480 We'll do the same thing. 198 00:13:15,250 --> 00:13:18,910 For, let's say, displaying a small message on the screen. 199 00:13:18,910 --> 00:13:20,830 So display small message. 200 00:13:23,410 --> 00:13:23,650 Oops. 201 00:13:23,650 --> 00:13:25,090 Don't forget your commas. 202 00:13:25,770 --> 00:13:31,230 And we're basically just going to keep going along and filling out our different DUI actions. 203 00:13:31,230 --> 00:13:40,020 So for example, updating the countdown, we reference our update countdown function for UI actions 204 00:13:40,020 --> 00:13:40,620 enum. 205 00:13:40,620 --> 00:13:43,650 For example, let's say we want to hide the task frame. 206 00:13:43,950 --> 00:13:46,770 So actions enum dot hide task frame. 207 00:13:46,770 --> 00:13:47,760 This one's actually pretty easy. 208 00:13:47,760 --> 00:13:53,880 We can just create a lambda function in here and then just do task frame dot visible equal to false. 209 00:13:53,880 --> 00:13:57,240 We can do the GUI actions. 210 00:13:58,350 --> 00:14:05,130 Enum dot collected money and again we'll have that reference our display money frame function. 211 00:14:06,470 --> 00:14:08,780 We could do it for the guy. 212 00:14:08,780 --> 00:14:14,660 Actions in um, outro frame, display, outro frame. 213 00:14:15,140 --> 00:14:23,150 And then we could do it for the guy actions enum dot died and this one will actually be pretty simple. 214 00:14:23,150 --> 00:14:24,440 Just create another Lambda function. 215 00:14:24,440 --> 00:14:31,790 And what this will do is it's going to spawn our display died frame function in a new thread because 216 00:14:31,790 --> 00:14:32,630 it's going to yield. 217 00:14:32,630 --> 00:14:40,910 So we'll use defer to spawn display died frame in a new thread and we'll have it fade onto the screen 218 00:14:40,910 --> 00:14:43,460 and stay faded on the screen for like around three seconds. 219 00:14:43,460 --> 00:14:45,110 And then we're going to fade it out. 220 00:14:45,110 --> 00:14:47,540 So that means we're going to have to wait for three seconds. 221 00:14:47,540 --> 00:14:52,820 And then that means once our screen is completely covered by the death frame, then we can use our start 222 00:14:52,820 --> 00:14:59,180 spectating function and display the spectating frame while our entire screen is blocked. 223 00:14:59,180 --> 00:15:01,940 So that way you know it doesn't look awkward on the screen. 224 00:15:01,940 --> 00:15:07,160 We're not going to immediately pop the spectating a frame onto the screen and switch the player's camera 225 00:15:07,160 --> 00:15:07,490 around. 226 00:15:07,490 --> 00:15:11,150 Instead, we're going to cover their screen with the died frame. 227 00:15:11,730 --> 00:15:15,210 And then we're going to put the spectating screen on and then it fades out. 228 00:15:15,210 --> 00:15:16,950 So that way it looks all smooth. 229 00:15:17,220 --> 00:15:24,930 Now you may be wondering, well aren't we going to do one for the I believe it's the, um, intro message? 230 00:15:24,930 --> 00:15:26,190 Don't you want to do it for this one? 231 00:15:26,190 --> 00:15:32,430 And we're not going to do it for this one because we're going to be using a bind all event, because 232 00:15:32,430 --> 00:15:39,210 our game handler here on the client is going to tell us when to exactly start displaying the intro messages. 233 00:15:39,450 --> 00:15:43,350 So this is going to be reserved for a different event for now. 234 00:15:44,190 --> 00:15:49,890 But other than that that means when our update GUI event gets fired, we get an action and the arguments 235 00:15:49,890 --> 00:15:57,060 applied to the action, and we can literally just check if inside of our case table, the action that 236 00:15:57,060 --> 00:15:58,710 the server wants us to do exists. 237 00:15:58,710 --> 00:16:05,880 So if this action in the case table exists, then we can literally just do case action and then call 238 00:16:05,880 --> 00:16:08,310 this function by putting two parentheses. 239 00:16:08,310 --> 00:16:11,820 And then we can pass whatever arguments came from the server. 240 00:16:11,820 --> 00:16:13,230 So we can just pass args here. 241 00:16:13,230 --> 00:16:16,350 And that's all we need to do for our update UI event. 242 00:16:17,380 --> 00:16:21,670 Now some other things that we're actually going to have to listen to in our initialize function is within 243 00:16:21,670 --> 00:16:22,810 our spectate frame. 244 00:16:22,810 --> 00:16:28,660 So there's a button in there called next which a player will click to go spectate the next player. 245 00:16:28,660 --> 00:16:30,700 So we'll have to listen for when that is clicked. 246 00:16:30,700 --> 00:16:33,460 But we're not going to fill out the functionality for this for now. 247 00:16:33,460 --> 00:16:40,000 And then we have to do the same thing for a previous button in our spectating frame to go back to spectate 248 00:16:40,000 --> 00:16:45,340 a previous player, and then also inside of our spectate frame, there is a respawn button and this 249 00:16:45,340 --> 00:16:51,010 is the button the player will click to request to respawn, and they'll get prompts to purchase a developer 250 00:16:51,010 --> 00:16:51,460 product. 251 00:16:51,460 --> 00:16:54,580 And again, we're not going to fill out the functionality for this quite yet. 252 00:16:55,030 --> 00:17:00,400 Now, what we can start doing is starting to fill out some of the functionality for these private functions. 253 00:17:00,400 --> 00:17:04,780 So we can go ahead and start off, for example, with our update objectives function. 254 00:17:05,850 --> 00:17:10,770 So inside of our update objectives function, we get passed arguments from the server. 255 00:17:10,770 --> 00:17:18,900 And basically what we're going to do here is we're going to first loop through every single child inside 256 00:17:18,900 --> 00:17:21,810 our objective frame dot objective list. 257 00:17:21,810 --> 00:17:25,650 So there's a list in there that contains all of the objectives. 258 00:17:25,650 --> 00:17:28,560 And we're going to get any children inside of this list. 259 00:17:28,860 --> 00:17:32,700 And we're going to check if this child is a text label. 260 00:17:32,700 --> 00:17:37,200 If it is then we need to destroy it because we're refreshing our objective list. 261 00:17:37,200 --> 00:17:39,870 So we're going to get this child and destroy it. 262 00:17:39,870 --> 00:17:45,030 Once we have cleared out the objective list, then what we're going to do is we're going to loop through 263 00:17:45,030 --> 00:17:50,700 every single objective that got passed to us in that argument table, and we're going to create a new 264 00:17:50,700 --> 00:17:55,350 clone of that, uh, objective label reference that we made. 265 00:17:55,350 --> 00:17:56,880 So we're going to clone this. 266 00:17:57,090 --> 00:18:01,230 We're going to set the name of the clone equal to the objective name. 267 00:18:01,230 --> 00:18:05,670 We're going to set the text for the clone equal to the objective text. 268 00:18:05,670 --> 00:18:12,630 And then we're going to set the parent of this clone equal to our objective frame dot objective list. 269 00:18:13,470 --> 00:18:16,440 And then by default this clone is not going to be visible. 270 00:18:16,440 --> 00:18:19,560 So we need to make sure to set the visibility of this clone equal to true. 271 00:18:20,370 --> 00:18:27,630 So basically what's happening here is if I go to my main guy and I enable our objective frame here, 272 00:18:27,630 --> 00:18:34,260 and I copy this objective label example and I paste it in here, make it visible, what's going to happen 273 00:18:34,260 --> 00:18:39,030 is it's going to, uh, the name of this is going to change to whatever objective. 274 00:18:39,030 --> 00:18:42,210 So for example, if it's the money objective, we'll change the name to money. 275 00:18:42,210 --> 00:18:52,020 And the text will be something like, uh, earn $500 to pay for rent or something like that. 276 00:18:52,020 --> 00:18:54,840 So that's one of the objectives that will pop up on the screen. 277 00:18:54,840 --> 00:18:56,760 As you can see, it's got a nice border around it. 278 00:18:56,760 --> 00:19:00,090 And then the text shows us exactly what we need to complete. 279 00:19:00,090 --> 00:19:05,250 And if we get that objective fulfilled, then it's going to set this color to green and then fade it 280 00:19:05,250 --> 00:19:05,700 out. 281 00:19:05,700 --> 00:19:09,660 Or if we fail it, it'll set the color to red and then fade it out. 282 00:19:10,050 --> 00:19:12,270 But that's basically what's going to be happening. 283 00:19:12,600 --> 00:19:16,710 So let me go ahead and make this no longer visible. 284 00:19:16,710 --> 00:19:18,390 And we can go back to our script. 285 00:19:18,690 --> 00:19:22,230 The next function I guess we could go ahead and fill out is our add objective function. 286 00:19:22,230 --> 00:19:29,520 So what we're going to do is we're first going to check inside of our objective frame dot objective 287 00:19:29,520 --> 00:19:30,480 list. 288 00:19:30,480 --> 00:19:36,660 We're going to see if we already have this objective inside of our objective frame. 289 00:19:36,660 --> 00:19:46,980 So if uh objective frame objective list find first child and then pass the objective dot name if it 290 00:19:46,980 --> 00:19:49,740 already exists in there, then we're just going to return out of this function. 291 00:19:49,740 --> 00:19:53,490 Otherwise we're basically just going to do the exact same thing that we did here. 292 00:19:53,880 --> 00:20:00,690 We're just going to clone the objective label, and we're going to set the name and text equal to this 293 00:20:00,690 --> 00:20:01,710 objective. 294 00:20:01,710 --> 00:20:03,900 Make sure to set the visibility to true. 295 00:20:03,900 --> 00:20:07,260 And then what we're going to do is we're going to play a sound. 296 00:20:07,260 --> 00:20:12,660 So inside of our sound service we have a folder called GUI which stores some guy sounds. 297 00:20:12,660 --> 00:20:14,910 And we have an objective added sound. 298 00:20:14,910 --> 00:20:19,500 So whenever a player gets an objective added, this sound is going to play. 299 00:20:19,860 --> 00:20:24,090 And that way they know a new objective has been added to the game. 300 00:20:24,180 --> 00:20:29,220 So we can reference this in sound service dot gui, dot objective added. 301 00:20:29,220 --> 00:20:31,590 And we're just going to play the sound now. 302 00:20:31,590 --> 00:20:34,650 I guess we can just go ahead and continue filling out these different functions. 303 00:20:34,650 --> 00:20:38,730 So let's go ahead and fill out um our update all tasks function. 304 00:20:38,730 --> 00:20:42,120 So this gets passed a list of all the tasks. 305 00:20:42,120 --> 00:20:45,600 And we're basically just going to do the exact same thing that we did here. 306 00:20:46,630 --> 00:20:52,930 But instead we're going to loop through our task frame, and inside of there there's a task list. 307 00:20:52,930 --> 00:20:56,350 And we're going to make sure to destroy any previous children in there. 308 00:20:56,350 --> 00:21:01,120 And then we're going to get every single task within our task list. 309 00:21:02,590 --> 00:21:06,370 And then we're going to clone instead our task label. 310 00:21:08,560 --> 00:21:13,090 Um, actually, let me just change this to tea, and then we could do tea. 311 00:21:13,090 --> 00:21:13,960 Name? 312 00:21:13,960 --> 00:21:14,440 Tea. 313 00:21:14,440 --> 00:21:15,550 Text. 314 00:21:16,660 --> 00:21:20,710 And then set the parent equal to the task frame dot task list. 315 00:21:21,510 --> 00:21:24,090 And that looks pretty good there as well. 316 00:21:24,090 --> 00:21:29,250 And I think actually what we'll also do is we'll make sure to enable the task frame when this happens. 317 00:21:29,250 --> 00:21:31,110 So we'll set the visibility to true. 318 00:21:31,110 --> 00:21:36,720 And then we're going to do the same thing for the objective frame just to make sure that it's all visible 319 00:21:36,720 --> 00:21:37,920 on our screen. 320 00:21:40,510 --> 00:21:41,020 Okay. 321 00:21:41,020 --> 00:21:44,920 So the next function we can go ahead and fill out I think is our update task function. 322 00:21:44,920 --> 00:21:52,720 So the purpose of this is to refer to an already existing task and update the value for this task. 323 00:21:52,720 --> 00:21:56,050 So what we're going to do is we're going to make a variable in here. 324 00:21:56,050 --> 00:21:58,060 We're going to call it which task. 325 00:21:58,420 --> 00:22:00,670 And it's going to be equal to args. 326 00:22:00,670 --> 00:22:04,600 And we'll have a key in this table called task to update. 327 00:22:04,600 --> 00:22:09,280 So the server will tell us which task or the name of the task we need to update. 328 00:22:09,490 --> 00:22:14,740 And then what we're going to do is we're going to get the text that's also supplied by the server in 329 00:22:14,740 --> 00:22:16,180 this arguments table. 330 00:22:16,960 --> 00:22:23,530 And now what we're going to do is we're going to find this task element inside of our task frame task 331 00:22:23,530 --> 00:22:23,860 list. 332 00:22:23,860 --> 00:22:26,410 And we're going to find first child. 333 00:22:26,410 --> 00:22:31,750 Which task if this task does not exist for some reason. 334 00:22:32,550 --> 00:22:36,090 Then we'll just create a new, uh, task element. 335 00:22:36,090 --> 00:22:43,800 So we're basically just going to copy this here, create a clone and set the name equal to, um, which 336 00:22:43,800 --> 00:22:47,760 task and then set the text equal to args. 337 00:22:47,760 --> 00:22:49,410 Or actually we start it in the variable up here. 338 00:22:49,410 --> 00:22:51,180 So we'll just set it equal to the text. 339 00:22:51,600 --> 00:22:56,250 So just in case this for some reason this task that the server wants us to update does not exist. 340 00:22:56,250 --> 00:22:58,020 We're going to quickly create it. 341 00:22:59,950 --> 00:23:04,510 Otherwise, if it, uh, does exist, then we just need to do task element. 342 00:23:04,510 --> 00:23:08,950 Dot text is equal to the text passed from the server. 343 00:23:09,520 --> 00:23:13,690 I guess the next function we can go ahead and fill out is our display intro message function. 344 00:23:13,690 --> 00:23:18,520 So what we're going to do here is we're going to loop through every single message inside of our message 345 00:23:18,520 --> 00:23:19,330 table. 346 00:23:20,070 --> 00:23:24,720 And where we're going to do is we're going to refer to our message frame, and we're going to set the 347 00:23:24,720 --> 00:23:29,970 text in the text label that's in there equal to this particular message. 348 00:23:30,360 --> 00:23:34,920 And then inside of the sound service there is another sound in here called boom. 349 00:23:34,920 --> 00:23:42,720 So each time a new message is displayed we're going to play the sound pretty nice. 350 00:23:42,720 --> 00:23:47,790 So we're going to do guy dot boom and then play the sound. 351 00:23:48,150 --> 00:23:52,650 And then we're going to wait for the delay between each message. 352 00:23:52,650 --> 00:23:56,610 So this is going to loop through every single message for example that we get past here. 353 00:23:56,610 --> 00:23:59,400 It's going to play the boom sound three different times. 354 00:23:59,970 --> 00:24:03,960 And then after that is over then we need to go ahead and fade out the guy. 355 00:24:03,960 --> 00:24:08,130 So what we could do is we could loop through every single descendant. 356 00:24:08,770 --> 00:24:10,630 Inside of our message frame. 357 00:24:10,630 --> 00:24:17,200 So get descendants and we're going to do is we're going to fade out each of these items so we can do 358 00:24:17,230 --> 00:24:18,370 task dot spawn. 359 00:24:18,370 --> 00:24:21,910 And we're going to spawn our fade element and a new thread. 360 00:24:21,910 --> 00:24:25,000 And we're going to pass to this the descendant. 361 00:24:25,210 --> 00:24:27,970 We can fade it out after like let's say one second. 362 00:24:27,970 --> 00:24:30,790 And we want to set the transparency to one. 363 00:24:30,910 --> 00:24:35,170 So every single descendant and our message frame is going to be completely faded out. 364 00:24:35,260 --> 00:24:42,370 And then what we could do is once the message frame or the intro message frame has been faded out, 365 00:24:42,370 --> 00:24:48,490 then inside of the sound service, inside of the ambience folder, there's a folder called weather, 366 00:24:48,490 --> 00:24:52,000 and then there's a rain sound and we're just going to play this sound. 367 00:24:52,000 --> 00:24:56,320 So this sound is going to continually loop in our game because it's going to be raining. 368 00:24:56,320 --> 00:24:59,860 And again, we're just adding more nice ambience into the game. 369 00:25:00,720 --> 00:25:03,570 And then after that, we're going to fade. 370 00:25:03,870 --> 00:25:06,090 Um, our message frame itself. 371 00:25:06,860 --> 00:25:12,020 Because we didn't pass that inside of this loop, because it's looping through every single descendant, 372 00:25:12,020 --> 00:25:13,490 but not the message frame itself. 373 00:25:13,490 --> 00:25:16,430 So we need to make sure to also fan out the message frame. 374 00:25:16,430 --> 00:25:20,750 And since this function is going to be yielding after it's finished yielding, then we can set the message 375 00:25:20,750 --> 00:25:23,750 frame dot visibility equal to false. 376 00:25:24,400 --> 00:25:31,930 And I think what would also be nice is that right, as we begin to fade out the message frame, we should 377 00:25:31,930 --> 00:25:33,430 play another boom sound. 378 00:25:34,020 --> 00:25:34,740 Perfect. 379 00:25:35,630 --> 00:25:36,140 Okay. 380 00:25:36,140 --> 00:25:39,770 So the next function we can go ahead and fill out is our fulfill task function. 381 00:25:39,770 --> 00:25:42,830 So what do we want to do when we want to fulfill a task. 382 00:25:42,830 --> 00:25:46,280 Well first we need to specify which task we want to fulfill. 383 00:25:46,280 --> 00:25:50,480 So which task is equal to args dot fulfill task. 384 00:25:50,480 --> 00:25:54,620 So the server again is going to provide to us which task has been fulfilled. 385 00:25:54,620 --> 00:26:00,560 And then we're going to get the text passed to this which is args dot text. 386 00:26:00,560 --> 00:26:03,620 And then what we're going to do is we're going to get this particular task. 387 00:26:03,620 --> 00:26:10,610 So fulfilled task is equal to task frame dot task list. 388 00:26:10,610 --> 00:26:16,940 We're going to find first child of this particular task that we need to fulfill. 389 00:26:17,970 --> 00:26:20,640 If this fulfilled task exists. 390 00:26:21,090 --> 00:26:24,960 So if a filled task. 391 00:26:26,100 --> 00:26:29,100 Then we can set the fulfilled task. 392 00:26:29,430 --> 00:26:31,890 Dot text. 393 00:26:32,890 --> 00:26:39,520 Equal to the text passed to this function because as we are fulfilling tasks, for example, let's say 394 00:26:39,520 --> 00:26:41,170 we completed two out of three toilets. 395 00:26:41,170 --> 00:26:46,300 Well, once we finish three out of three toilets, then that means our task needs to be fulfilled, 396 00:26:46,300 --> 00:26:47,890 but we still have to update the text. 397 00:26:47,890 --> 00:26:51,220 Otherwise it'll still say something like two out of three instead of three out of three. 398 00:26:51,220 --> 00:26:53,110 So then we update the text. 399 00:26:53,290 --> 00:26:58,630 Then what we're going to do is we're going to get this fulfilled task, and we're going to set the text 400 00:26:58,630 --> 00:27:02,170 color three equal to our green color. 401 00:27:02,440 --> 00:27:06,280 And then what we could do is we could wait a random amount of time like four seconds. 402 00:27:06,280 --> 00:27:08,440 So it'll stay on the screen for four seconds. 403 00:27:08,800 --> 00:27:18,550 And then what we're going to do is we're going to fade element, which is going to be our um, task 404 00:27:18,550 --> 00:27:18,820 itself. 405 00:27:18,820 --> 00:27:22,030 So we'll just pass our fulfilled task. 406 00:27:23,000 --> 00:27:29,150 Uh, will have this last something like one second, and then we'll set the transparency to one. 407 00:27:29,300 --> 00:27:34,520 And then we're also going to want to do the same thing for the UI stroke that is going to be inside 408 00:27:34,520 --> 00:27:35,600 of this task. 409 00:27:35,600 --> 00:27:39,200 And what we could do is we could actually spawn that in a separate thread. 410 00:27:39,200 --> 00:27:42,740 So we'll spawn our fade element function and a new thread. 411 00:27:42,740 --> 00:27:47,810 We're going to pass fulfilled task dot UI stroke. 412 00:27:47,810 --> 00:27:49,220 There's a UI stroke in there. 413 00:27:49,220 --> 00:27:53,540 Again we're going to fade it out for one second and set the transparency to one. 414 00:27:53,540 --> 00:28:00,890 And then after this is finished yielding right here, then we can just go ahead and destroy this fulfilled 415 00:28:00,920 --> 00:28:03,110 task because we no longer need it. 416 00:28:03,590 --> 00:28:04,040 All right. 417 00:28:04,040 --> 00:28:04,760 Looks good. 418 00:28:04,760 --> 00:28:11,390 Now we can basically just copy all of this and do the exact same thing for fulfilling an objective. 419 00:28:11,390 --> 00:28:18,980 But instead we can, uh, do which objective, which is going to be equal to args. 420 00:28:18,980 --> 00:28:24,980 And from the server we'll pass something like, uh, fulfilled objective name. 421 00:28:24,980 --> 00:28:26,510 We could do something like that. 422 00:28:26,750 --> 00:28:29,420 We'll get, uh, which objective we need to update. 423 00:28:29,420 --> 00:28:32,090 We don't need text here for this objective though. 424 00:28:32,090 --> 00:28:34,370 And then we can get the fulfilled. 425 00:28:36,130 --> 00:28:43,660 Objective, and then we can go ahead and look inside of our objective frame dot objective list and find 426 00:28:43,660 --> 00:28:47,710 first child which matches the objective name. 427 00:28:47,980 --> 00:28:51,550 And then if this fulfilled objective exists. 428 00:28:53,150 --> 00:28:55,160 Then we can delete this here. 429 00:28:56,400 --> 00:29:00,360 Will set the fulfilled objective equal to the green color. 430 00:29:00,360 --> 00:29:06,300 We'll wait four seconds again, and then we will fade out the UI stroke in this fulfilled objective 431 00:29:06,300 --> 00:29:10,800 as well, and then fade out the fulfilled objective itself, and then we destroy it. 432 00:29:11,480 --> 00:29:17,570 Now, if we fail an objective, uh, basically, we'll just do the exact same thing that we did here, 433 00:29:17,570 --> 00:29:21,980 but instead, we'll get past the failed objective so we could do failed. 434 00:29:21,980 --> 00:29:23,210 Objective name? 435 00:29:23,330 --> 00:29:24,500 Which objective? 436 00:29:24,500 --> 00:29:25,820 It's going to be a failed objective. 437 00:29:25,820 --> 00:29:29,870 So we'll just pass failed OBJ here and then just copy this. 438 00:29:30,640 --> 00:29:34,330 Paste it here, paste it here, paste it here. 439 00:29:35,780 --> 00:29:37,910 Paste it here and then paste it here. 440 00:29:37,910 --> 00:29:42,380 And instead we want to set the color equal to our red color. 441 00:29:43,040 --> 00:29:43,490 All right. 442 00:29:43,490 --> 00:29:49,850 So to display a small message on the screen, what we could do is we could get the text from ARGs and 443 00:29:49,850 --> 00:29:52,100 we'll get past a key like text. 444 00:29:52,100 --> 00:29:54,320 And then what we need to do here. 445 00:29:54,990 --> 00:30:01,260 Is, since this small text label is going to be faded in and out, we need to first check if the small 446 00:30:01,260 --> 00:30:06,750 message label dot text transparency is not equal to one. 447 00:30:06,870 --> 00:30:11,790 So if our small message label is actually visible on the screen still, then we need to fade it out 448 00:30:11,790 --> 00:30:13,650 before we can update the text on it. 449 00:30:13,650 --> 00:30:18,000 So we're going to call our fade element function on our small message label. 450 00:30:18,210 --> 00:30:22,380 We'll fade it out for like one second to make it completely transparent. 451 00:30:22,380 --> 00:30:27,810 And then after this is finished yielding, then we can set the small message label dot text equal to 452 00:30:27,810 --> 00:30:28,740 this text. 453 00:30:29,810 --> 00:30:34,760 And then what we could do is play another sound which is inside of our G folder. 454 00:30:34,760 --> 00:30:37,790 So this sound will play when we display a small message on the screen. 455 00:30:37,790 --> 00:30:38,630 So we'll play it. 456 00:30:39,220 --> 00:30:40,750 So that will let us know that. 457 00:30:40,750 --> 00:30:42,400 Hey, a message just popped up. 458 00:30:42,400 --> 00:30:47,380 So sound service dot g dot small message play. 459 00:30:47,970 --> 00:30:52,140 And then now that we're playing this sound, we need to fade the small message back onto the screen 460 00:30:52,140 --> 00:30:54,600 so we can call again our fade element function. 461 00:30:54,600 --> 00:30:56,670 Pass our small message label. 462 00:30:56,670 --> 00:31:01,290 We can again do something for like one second, and then we want to make it fully opaque. 463 00:31:02,360 --> 00:31:05,390 And then after that, we can wait for another random amount of time. 464 00:31:05,390 --> 00:31:06,830 We can wait for like five seconds. 465 00:31:06,830 --> 00:31:10,490 So the message will be visible on our screen for a total of five seconds. 466 00:31:10,820 --> 00:31:18,020 And before we fade it out, we need to verify that first our small message label dot transparency is 467 00:31:18,020 --> 00:31:19,490 still equal to zero. 468 00:31:19,640 --> 00:31:24,920 And we need to make sure that our small message label dot text is still equal to the original text that 469 00:31:24,920 --> 00:31:26,600 was passed to our function. 470 00:31:26,900 --> 00:31:32,540 Because let's say this message gets cut out by another message that the player interacts with, well, 471 00:31:32,540 --> 00:31:34,340 we don't want to fade it out prematurely. 472 00:31:34,340 --> 00:31:40,250 We only want to fade it out when we know that the transparency is still visible, and that the text 473 00:31:40,250 --> 00:31:45,050 inside of this message label is still equal to the same text that we got passed originally. 474 00:31:45,050 --> 00:31:46,640 After this wait statement is up. 475 00:31:46,640 --> 00:31:52,670 If it is, then we're all clear to go ahead and fade our small message label back to be transparent. 476 00:31:53,500 --> 00:31:56,920 The next function we can fill out is our display money frame function. 477 00:31:57,010 --> 00:32:00,490 So again what we're going to get past is some text. 478 00:32:01,430 --> 00:32:05,540 And we're going to get past, uh, in arguments. 479 00:32:05,540 --> 00:32:08,270 We can get past a number from the server. 480 00:32:08,540 --> 00:32:14,000 And then basically what we could do is we'll put a string here, we could do like plus, and then I'll 481 00:32:14,000 --> 00:32:18,110 put a dollar sign and then we'll just concatenate this with a number. 482 00:32:18,110 --> 00:32:22,370 So when we collect some money the server is going to tell us how much. 483 00:32:22,370 --> 00:32:29,570 And then we'll display a string like uh plus dollar like maybe five bucks or something like that. 484 00:32:29,570 --> 00:32:30,140 Whatever. 485 00:32:32,440 --> 00:32:36,100 So we'll get past args dot number. 486 00:32:36,640 --> 00:32:42,160 And then inside of our money frame there's a label in there called the amount label. 487 00:32:42,160 --> 00:32:45,850 And we're going to set the text equal to this new text we just created. 488 00:32:46,180 --> 00:32:51,430 We're going to set the money frame dot position equal to a random position on the screen. 489 00:32:51,430 --> 00:32:56,410 So each time a player collects money, it's not always going to pop up on the same place on their screen. 490 00:32:56,410 --> 00:32:59,440 So we can set the position equal to a new utum two. 491 00:33:00,660 --> 00:33:04,440 And this is where we're going to use our RNG function to pick a random place. 492 00:33:04,440 --> 00:33:10,230 So we'll do RNG next number for the X scale anywhere between 0.3 and 0.7. 493 00:33:10,410 --> 00:33:12,540 We're going to do zero for the X offset. 494 00:33:12,540 --> 00:33:21,540 And then for the Y scale we can do RNG next number anywhere between 0.2 and 0.9 scale on the screen 495 00:33:21,540 --> 00:33:24,330 and then zero for the Y offset. 496 00:33:24,900 --> 00:33:27,360 And let me just space this out so it looks nicer. 497 00:33:28,300 --> 00:33:31,270 Now we can do money frame visibility equal to true. 498 00:33:31,810 --> 00:33:36,460 And then what we need to do is we actually need to fade this money frame onto the screen. 499 00:33:36,460 --> 00:33:40,630 So we need to spawn our fade element function in a new thread. 500 00:33:40,630 --> 00:33:46,600 We're going to pass the money frame dot image label, and we're going to fade it in within 0.1 seconds. 501 00:33:46,600 --> 00:33:48,520 And we're going to make it fully opaque. 502 00:33:49,290 --> 00:33:54,300 And then what we're going to do is inside of the sound service and guy, there is a sound for when we 503 00:33:54,300 --> 00:33:58,320 collect money, so collect money, we're going to play the sound and I'll give you a demo of it here 504 00:33:58,320 --> 00:33:59,040 real quick. 505 00:33:59,490 --> 00:34:01,470 So that will play when we collect money. 506 00:34:02,110 --> 00:34:07,930 And then the other thing we need to fade onto the screen as well is the money frame dot amount label. 507 00:34:07,930 --> 00:34:10,030 Because again, that's also going to be invisible. 508 00:34:10,060 --> 00:34:13,720 We're also going to do 0.1 seconds and fade it to be opaque. 509 00:34:14,890 --> 00:34:20,020 And then once that's done, we're going to use the tween service to create a new tween on our money 510 00:34:20,020 --> 00:34:26,980 frame because we want to, uh, move this, uh, frame to slowly go upwards. 511 00:34:26,980 --> 00:34:30,910 So it looks like it's animated and stuff like that makes it look nice. 512 00:34:30,910 --> 00:34:34,960 So we could do tween info dot new. 513 00:34:36,260 --> 00:34:39,440 Uh, we can move it up for something like 1.5 seconds. 514 00:34:39,650 --> 00:34:47,270 And for the position, we want to set it equal to the current money frame dot position. 515 00:34:47,270 --> 00:34:49,460 But we want to add a new offset. 516 00:34:49,460 --> 00:34:51,530 So we'll add a new Utum two. 517 00:34:52,800 --> 00:34:56,760 And we're going to move it up in the Y direction. 518 00:34:56,760 --> 00:35:02,220 And in order to do that, we actually need to subtract on the Y scale. 519 00:35:02,220 --> 00:35:04,980 So we could do like -0.1. 520 00:35:06,080 --> 00:35:07,580 And then we'll just play this tween. 521 00:35:07,580 --> 00:35:10,880 So it will cause our money frame to like slowly move up. 522 00:35:10,880 --> 00:35:15,950 And while it's slowly moving up, we also want to fade it out at the exact same time. 523 00:35:15,950 --> 00:35:20,870 So again we're going to spawn in a new thread our fade element. 524 00:35:21,140 --> 00:35:24,020 We're going to pass the money frame dot image label. 525 00:35:24,170 --> 00:35:29,510 And we also want to take 1.5 seconds and fade it to be completely transparent. 526 00:35:29,930 --> 00:35:33,740 And then we're going to do the exact same thing for the amount label as well. 527 00:35:34,040 --> 00:35:38,420 We're going to make it take 1.5 seconds and we're going to fade it to be completely transparent. 528 00:35:38,930 --> 00:35:41,180 And that's all we need to do for this function as well. 529 00:35:41,960 --> 00:35:42,620 Okay. 530 00:35:42,620 --> 00:35:47,420 And the last function I think we can go ahead and fill out is our display died frame. 531 00:35:47,420 --> 00:35:51,410 We're not going to have to worry about these functions for now, because this is going to be future 532 00:35:51,410 --> 00:35:54,350 implementation that we'll be adding later in the course. 533 00:35:54,800 --> 00:36:01,400 So inside our display died frame, what we could do is we could play inside of the sound service guy 534 00:36:01,430 --> 00:36:05,360 dot died, and we'll play that sound and I'll show you what it is. 535 00:36:06,350 --> 00:36:11,360 You probably heard of the sound before, but it's a popular meme sound for when somebody dies, and 536 00:36:11,360 --> 00:36:13,310 I believe it was a Dark Souls game. 537 00:36:13,900 --> 00:36:16,150 But anyways, we're going to play that sound. 538 00:36:16,150 --> 00:36:19,720 We're going to set the visibility of our death frame equal to true. 539 00:36:20,020 --> 00:36:22,570 And then we're going to go ahead and fade. 540 00:36:22,570 --> 00:36:27,010 Um, we're going to fade our, uh, death frame. 541 00:36:27,920 --> 00:36:32,480 And we'll fade it for like, point five seconds to be fully, uh, visible. 542 00:36:32,840 --> 00:36:35,000 And then we want to do the same thing for our text as well. 543 00:36:35,000 --> 00:36:36,290 So we'll spawn that. 544 00:36:37,260 --> 00:36:40,980 Fade element function and a new thread will pass the death frame. 545 00:36:40,980 --> 00:36:43,740 And there's a text label in there that says you died or whatever. 546 00:36:43,740 --> 00:36:46,020 And again we'll have that take 0.5 seconds. 547 00:36:46,830 --> 00:36:52,020 And then we'll have this be stuck displaying on the screen for three seconds, and then we're going 548 00:36:52,020 --> 00:36:52,830 to fade it back out. 549 00:36:52,830 --> 00:36:54,780 So we can basically just copy this. 550 00:36:55,110 --> 00:36:58,740 And instead we'll set the transparency equal to one. 551 00:37:00,670 --> 00:37:03,790 Alrighty, so that's pretty much all we're going to fill out for now. 552 00:37:03,910 --> 00:37:08,050 Of course, this lecture is already probably getting too long, and we're going to continue working 553 00:37:08,050 --> 00:37:10,240 on and scripting our game in the next lecture. 554 00:37:10,240 --> 00:37:11,290 See you there.